<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<%@ page import="com.msmall.base.util.ConstantDB" language="java"%>
<c:set var="AVALIABLE" value="<%=ConstantDB.AVALIABLE%>"></c:set>
<c:set var="UNAVALIABLE" value="<%=ConstantDB.UNAVALIABLE%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="REPLY" value="<%=ConstantDB.REPLY%>"></c:set>
<c:set var="UNREPLY" value="<%=ConstantDB.UNREPLY%>"></c:set>
<c:set var="FROM_TRANSFER" value="<%=ConstantDB.FROM_TRANSFER%>"></c:set>
<c:set var="FROM_ORIGINAL" value="<%=ConstantDB.FROM_ORIGINAL%>"></c:set>
<c:set var="SEGMENT_ID_WIKI_NAV" value="<%=ConstantDB.SEGMENT_ID_WIKI_NAV%>"></c:set>

<div class="que_module martop10">
	<div class="w740 fl">
		<c:set var="currentSeg" value="${wikiSegment}"/>
		<div class="qlistques">
			<div id="wikiTabs" class="qlistquesnav">
				<p class="qlistquesnavbg">
					<c:out value="${currentSeg.current.title}"></c:out>
				</p>
			</div>
		</div>
		<c:choose>
			<c:when test="${not empty article}">
				<c:if test="${page.pageIndex < 2}">
					<div class="qshowanswerdiv">
						<c:set var="authorizeUpdateWiki"><ms:wiki action="create" id="${userInfo.userid}"/></c:set>
						<c:if test="${authorizeUpdateWiki eq true}">
							<a href="<c:url value='/wiki/update.do?articleid=${article.articleid}'/>">更新字典/百科</a>
						</c:if>
					</div>
					<div class="qshowanswerdiv">
						<div class="dictionshow">
							<jsp:include page="/${article.htmlPath}"></jsp:include>
						</div>
					</div>
				</c:if>
			</c:when>
			<c:otherwise>
				<div class="qshowanswerdiv">
					<div class="dictionshow">
						<tiles:insertDefinition name="html.klg.article.notexist"></tiles:insertDefinition>
					</div>
				</div>
			</c:otherwise>
		</c:choose>
		<c:choose>
			<c:when test="${not empty article || page.pageIndex>1}">
				<div class="qlistques martop10">
					<div class="qlistquesnav">
					<p class="qlistquesnavbg">网友评论</p>
					</div>
				</div>
				<div class="qshowanswerdiv">
					<dl id="article_reply_new" class="dictioncommdl" style="display:none"></dl>
					<c:forEach var="articleReply" items="${page.items}" varStatus="status">
						<c:choose>
							<c:when test="${articleReply.enabled == AVALIABLE}">
								<dl class="dictioncommdl">
									<dt>
										<ms:user type="nickname" link="true" userid="${articleReply.userId}" nickname="${articleReply.nickname}"></ms:user>
										&nbsp;&nbsp;&nbsp;
										<fmt:formatDate value="${articleReply.createTime}" pattern="yyyy-MM-dd HH:mm"/>
									</dt>
									<dd>
										<c:out value="${articleReply.content}"></c:out>
									</dd>
								</dl>
							</c:when>
							<c:otherwise>
							</c:otherwise>
						</c:choose>
					</c:forEach>
					
					<p class="padtop10 s666" id="div_articlReply_error" style="display:none">
					</p>
					<form id="f_new_articleReply" action="<c:url value='/klg/article/reply.do' />" method="post">
						<input type="hidden" name="reply.articleid" value="${article.articleid}"/>
						<p class="tc padtop10">
							<textarea id="articleReply_content" name="reply.content" class="qshowanswerform">
								<c:out value='${reply.content}'/>
							</textarea>
						</p>
					</form>
					<p class="padtop10 s666">
						<input onclick="javascript:ajaxSubmitFollow('f_new_articleReply', 'div_articlReply_error', 'article_reply_new', 'articleReply_content');" class="but62" type="button" value="发表评论" name="">
						文明发言，请遵守相关规定
					</p>
				</div>
			</c:when>
		</c:choose>
	</div>
	<div class="w250 fr">
		<tiles:insertDefinition name="html.wiki.index.bbs"></tiles:insertDefinition>
		<tiles:insertDefinition name="html.wiki.index.klg"></tiles:insertDefinition>
	</div>
</div>
<script>
function ajaxSubmitFollow(formid, errorid, newid, contentid){
	$("#"+errorid).html();
	$("#"+errorid).css("display", "none");
	$.ajax({
		type : "POST",
		url : $("#"+formid).attr('action'),
		data : $("#"+formid).serialize(),
		dataType:"xml", 
		timeout:20000,
		success : function(data){
			if($(data).find('result').text().toUpperCase().indexOf("TRUE") < 0){
				$("#"+errorid).html($(data).find('content').text());
				$("#"+errorid).css("display", "block");
			}else{
				var content = "<dt'><c:out value='${nickname}'/>&nbsp;&nbsp;&nbsp;"+ formatDate(new Date(), "yyyy-MM-dd HH:mm"); 
				content = content + "</dt><dd>";
				content = content + "您的回复正等待审核....<br/><br/>";
				content = content + $("#"+contentid).val();
				content = content + "</dd>";
				$("#"+newid).html(content);
				$("#"+newid).css("display", "block");
				$("#"+contentid).val('');
			}
		},
		error: function(){
		}
	});
}
</script>